﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Threading.Tasks;
using JX.Core;
using JX.Core.Entity;
using JX.Infrastructure.Common;
using MyADO;

namespace JX.ADO
{
	/// <summary>
	/// 数据库表：Users 的仓储实现类.
	/// </summary>
	public partial class UsersRepositoryADO : IUsersRepositoryADO
	{
		#region 数据上下文
		/// <summary>
		/// 数据上下文
		/// </summary>
		private IDBOperator _DB;

		/// <summary>
		/// 构造器注入
		/// </summary>
		/// <param name="DB"></param>
		public UsersRepositoryADO(IDBOperator DB)
		{
			_DB = DB;
		}
		#endregion
		
		#region 得到第一行第一列的值
		/// <summary>
		/// 得到第一行第一列的值
		/// </summary>
		/// <param name="statistic">要返回的字段（如：count(*) 或者 UserName）</param>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual string GetScalar(string statistic, string strWhere = "", Dictionary<string, object> dict = null)
		{
			string strSQL = "select " + statistic + " from Users where 1=1 ";
			if (!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			return _DB.ExeSQLScalar(strSQL, dict);
		}
		/// <summary>
		/// 得到第一行第一列的值（异步方式）
		/// </summary>
		/// <param name="statistic">要返回的字段（如：count(*) 或者 UserName）</param>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<string> GetScalarAsync(string statistic, string strWhere = "", Dictionary<string, object> dict = null)
		{
			string strSQL = "select " + statistic + " from Users where 1=1 ";
			if (!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			return await Task.Run(() => _DB.ExeSQLScalar(strSQL, dict));
		}
		#endregion
		
		#region 得到所有行数
		/// <summary>
		/// 得到所有行数
		/// </summary>
		/// <returns></returns>
		public virtual int GetCount()
		{
			return DataConverter.CLng(GetScalar("count(*)"), 0);
		}
		/// <summary>
		/// 得到所有行数（异步方式）
		/// </summary>
		/// <returns></returns>
		public virtual async Task<int> GetCountAsync()
		{
			return DataConverter.CLng(await GetScalarAsync("count(*)"), 0);
		}

		/// <summary>
		/// 得到所有行数
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual int GetCount(string strWhere, Dictionary<string, object> dict = null)
		{
			return DataConverter.CLng(GetScalar("count(*)", strWhere, dict), 0);
		}
		/// <summary>
		/// 得到所有行数（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<int> GetCountAsync(string strWhere, Dictionary<string, object> dict = null)
		{
			return DataConverter.CLng(await GetScalarAsync("count(*)", strWhere, dict), 0);
		}
		#endregion
		
		#region 得到最大ID、最新ID
		/// <summary>
		/// 得到数据表中第一个主键的最大数值
		/// </summary>
		/// <returns></returns>
		public virtual int GetMaxID()
		{
			return _DB.GetMaxID("Users", "UserID");
		}
		/// <summary>
		/// 得到数据表中第一个主键的最大数值（异步方式）
		/// </summary>
		/// <returns></returns>
		public virtual async Task<int> GetMaxIDAsync()
		{
			return await Task.Run(() => _DB.GetMaxID("Users", "UserID"));
		}

		/// <summary>
		/// 得到数据表中第一个主键的最大数值加1
		/// </summary>
		/// <returns></returns>
		public virtual int GetNewID()
		{
			return GetMaxID() + 1;
		}
		/// <summary>
		/// 得到数据表中第一个主键的最大数值加1（异步方式）
		/// </summary>
		/// <returns></returns>
		public virtual async Task<int> GetNewIDAsync()
		{
			return await GetMaxIDAsync() + 1;
		}
		#endregion
		
		#region 验证是否存在
		/// <summary>
		/// 检查数据是否存在
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual bool IsExist(string strWhere, Dictionary<string, object> dict = null)
		{
			if (GetCount(strWhere, dict) == 0)
			{
				return false;
			}
			return true;
		}

		/// <summary>
		/// 检查数据是否存在（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<bool> IsExistAsync(string strWhere, Dictionary<string, object> dict = null)
		{
			int count = await GetCountAsync(strWhere, dict);
			if (count == 0)
			{
				return false;
			}
			return true;
		}
		#endregion
		
		#region 添加
		/// <summary>
		/// 增加一条记录
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <returns></returns>
		public virtual bool Add(UsersEntity entity)
		{
			if(entity.UserID <= 0) entity.UserID=GetNewID();
			Dictionary<string, object> dict = new Dictionary<string, object>();
			GetParameters(entity,dict);

			string strSQL = "insert into Users ("+
							"UserID,"+
							"GroupID,"+
							"CompanyID,"+
							"ClientID,"+
							"UserType,"+
							"UserName,"+
							"TrueName,"+
							"UserPassword,"+
							"LastPassword,"+
							"Question,"+
							"Answer,"+
							"Email,"+
							"Mobile,"+
							"Sex,"+
							"RegTime,"+
							"JoinTime,"+
							"LoginTimes,"+
							"LoginTime,"+
							"PresentTime,"+
							"LoginIP,"+
							"PasswordChangedTime,"+
							"LockoutTime,"+
							"LoginFailedCount,"+
							"FirstFailedTime,"+
							"FailedAnswerCount,"+
							"FirstFailedAnswerTime,"+
							"UserStatus,"+
							"CheckNum,"+
							"IsResetPassword,"+
							"UserCultureName,"+
							"UserFace,"+
							"FaceWidth,"+
							"FaceHeight,"+
							"Sign,"+
							"PrivacySetting,"+
							"Balance,"+
							"UserPoint,"+
							"UserExp,"+
							"ConsumeMoney,"+
							"ConsumePoint,"+
							"ConsumeExp,"+
							"PostItems,"+
							"PassedItems,"+
							"RejectItems,"+
							"DeleteItems,"+
							"EndTime,"+
							"IsInheritGroupRole,"+
							"UserSetting,"+
							"UserFriendGroup,"+
							"PayPassword,"+
							"IsShowUpgradeTipsFalse,"+
							"LastAddPointTime,"+
							"QAPoint,"+
							"GetPasswordSid,"+
							"GetPasswordTime,"+
							"HonorType,"+
							"FrozenBalance,"+
							"CreditLines) "+
							"values("+
							"@UserID,"+
							"@GroupID,"+
							"@CompanyID,"+
							"@ClientID,"+
							"@UserType,"+
							"@UserName,"+
							"@TrueName,"+
							"@UserPassword,"+
							"@LastPassword,"+
							"@Question,"+
							"@Answer,"+
							"@Email,"+
							"@Mobile,"+
							"@Sex,"+
							"@RegTime,"+
							"@JoinTime,"+
							"@LoginTimes,"+
							"@LoginTime,"+
							"@PresentTime,"+
							"@LoginIP,"+
							"@PasswordChangedTime,"+
							"@LockoutTime,"+
							"@LoginFailedCount,"+
							"@FirstFailedTime,"+
							"@FailedAnswerCount,"+
							"@FirstFailedAnswerTime,"+
							"@UserStatus,"+
							"@CheckNum,"+
							"@IsResetPassword,"+
							"@UserCultureName,"+
							"@UserFace,"+
							"@FaceWidth,"+
							"@FaceHeight,"+
							"@Sign,"+
							"@PrivacySetting,"+
							"@Balance,"+
							"@UserPoint,"+
							"@UserExp,"+
							"@ConsumeMoney,"+
							"@ConsumePoint,"+
							"@ConsumeExp,"+
							"@PostItems,"+
							"@PassedItems,"+
							"@RejectItems,"+
							"@DeleteItems,"+
							"@EndTime,"+
							"@IsInheritGroupRole,"+
							"@UserSetting,"+
							"@UserFriendGroup,"+
							"@PayPassword,"+
							"@IsShowUpgradeTipsFalse,"+
							"@LastAddPointTime,"+
							"@QAPoint,"+
							"@GetPasswordSid,"+
							"@GetPasswordTime,"+
							"@HonorType,"+
							"@FrozenBalance,"+
							"@CreditLines)";
			
			return _DB.ExeSQLResult(strSQL,dict);
		}
		/// <summary>
		/// 增加一条记录（异步方式）
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <returns></returns>
		public virtual async Task<bool> AddAsync(UsersEntity entity)
		{
			if(entity.UserID <= 0) entity.UserID=GetNewID();
			Dictionary<string, object> dict = new Dictionary<string, object>();
			GetParameters(entity, dict);

			string strSQL = "insert into Users ("+
							"UserID,"+
							"GroupID,"+
							"CompanyID,"+
							"ClientID,"+
							"UserType,"+
							"UserName,"+
							"TrueName,"+
							"UserPassword,"+
							"LastPassword,"+
							"Question,"+
							"Answer,"+
							"Email,"+
							"Mobile,"+
							"Sex,"+
							"RegTime,"+
							"JoinTime,"+
							"LoginTimes,"+
							"LoginTime,"+
							"PresentTime,"+
							"LoginIP,"+
							"PasswordChangedTime,"+
							"LockoutTime,"+
							"LoginFailedCount,"+
							"FirstFailedTime,"+
							"FailedAnswerCount,"+
							"FirstFailedAnswerTime,"+
							"UserStatus,"+
							"CheckNum,"+
							"IsResetPassword,"+
							"UserCultureName,"+
							"UserFace,"+
							"FaceWidth,"+
							"FaceHeight,"+
							"Sign,"+
							"PrivacySetting,"+
							"Balance,"+
							"UserPoint,"+
							"UserExp,"+
							"ConsumeMoney,"+
							"ConsumePoint,"+
							"ConsumeExp,"+
							"PostItems,"+
							"PassedItems,"+
							"RejectItems,"+
							"DeleteItems,"+
							"EndTime,"+
							"IsInheritGroupRole,"+
							"UserSetting,"+
							"UserFriendGroup,"+
							"PayPassword,"+
							"IsShowUpgradeTipsFalse,"+
							"LastAddPointTime,"+
							"QAPoint,"+
							"GetPasswordSid,"+
							"GetPasswordTime,"+
							"HonorType,"+
							"FrozenBalance,"+
							"CreditLines) "+
							"values("+
							"@UserID,"+
							"@GroupID,"+
							"@CompanyID,"+
							"@ClientID,"+
							"@UserType,"+
							"@UserName,"+
							"@TrueName,"+
							"@UserPassword,"+
							"@LastPassword,"+
							"@Question,"+
							"@Answer,"+
							"@Email,"+
							"@Mobile,"+
							"@Sex,"+
							"@RegTime,"+
							"@JoinTime,"+
							"@LoginTimes,"+
							"@LoginTime,"+
							"@PresentTime,"+
							"@LoginIP,"+
							"@PasswordChangedTime,"+
							"@LockoutTime,"+
							"@LoginFailedCount,"+
							"@FirstFailedTime,"+
							"@FailedAnswerCount,"+
							"@FirstFailedAnswerTime,"+
							"@UserStatus,"+
							"@CheckNum,"+
							"@IsResetPassword,"+
							"@UserCultureName,"+
							"@UserFace,"+
							"@FaceWidth,"+
							"@FaceHeight,"+
							"@Sign,"+
							"@PrivacySetting,"+
							"@Balance,"+
							"@UserPoint,"+
							"@UserExp,"+
							"@ConsumeMoney,"+
							"@ConsumePoint,"+
							"@ConsumeExp,"+
							"@PostItems,"+
							"@PassedItems,"+
							"@RejectItems,"+
							"@DeleteItems,"+
							"@EndTime,"+
							"@IsInheritGroupRole,"+
							"@UserSetting,"+
							"@UserFriendGroup,"+
							"@PayPassword,"+
							"@IsShowUpgradeTipsFalse,"+
							"@LastAddPointTime,"+
							"@QAPoint,"+
							"@GetPasswordSid,"+
							"@GetPasswordTime,"+
							"@HonorType,"+
							"@FrozenBalance,"+
							"@CreditLines)";
			
			return await Task.Run(() => _DB.ExeSQLResult(strSQL, dict));
		}

		/// <summary>
		/// 增加一条记录，返回新的ID号。需要有一个单一主键，并且开启有标识符属性
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <returns></returns>
		public virtual int Insert(UsersEntity entity)
		{
			if(entity.UserID <= 0) entity.UserID=GetNewID();			
			Dictionary<string, object> dict = new Dictionary<string, object>();
			GetParameters(entity,dict);

			string strSQL = "insert into Users ("+
							"UserID,"+
							"GroupID,"+
							"CompanyID,"+
							"ClientID,"+
							"UserType,"+
							"UserName,"+
							"TrueName,"+
							"UserPassword,"+
							"LastPassword,"+
							"Question,"+
							"Answer,"+
							"Email,"+
							"Mobile,"+
							"Sex,"+
							"RegTime,"+
							"JoinTime,"+
							"LoginTimes,"+
							"LoginTime,"+
							"PresentTime,"+
							"LoginIP,"+
							"PasswordChangedTime,"+
							"LockoutTime,"+
							"LoginFailedCount,"+
							"FirstFailedTime,"+
							"FailedAnswerCount,"+
							"FirstFailedAnswerTime,"+
							"UserStatus,"+
							"CheckNum,"+
							"IsResetPassword,"+
							"UserCultureName,"+
							"UserFace,"+
							"FaceWidth,"+
							"FaceHeight,"+
							"Sign,"+
							"PrivacySetting,"+
							"Balance,"+
							"UserPoint,"+
							"UserExp,"+
							"ConsumeMoney,"+
							"ConsumePoint,"+
							"ConsumeExp,"+
							"PostItems,"+
							"PassedItems,"+
							"RejectItems,"+
							"DeleteItems,"+
							"EndTime,"+
							"IsInheritGroupRole,"+
							"UserSetting,"+
							"UserFriendGroup,"+
							"PayPassword,"+
							"IsShowUpgradeTipsFalse,"+
							"LastAddPointTime,"+
							"QAPoint,"+
							"GetPasswordSid,"+
							"GetPasswordTime,"+
							"HonorType,"+
							"FrozenBalance,"+
							"CreditLines) "+
							"values("+
							"@UserID,"+
							"@GroupID,"+
							"@CompanyID,"+
							"@ClientID,"+
							"@UserType,"+
							"@UserName,"+
							"@TrueName,"+
							"@UserPassword,"+
							"@LastPassword,"+
							"@Question,"+
							"@Answer,"+
							"@Email,"+
							"@Mobile,"+
							"@Sex,"+
							"@RegTime,"+
							"@JoinTime,"+
							"@LoginTimes,"+
							"@LoginTime,"+
							"@PresentTime,"+
							"@LoginIP,"+
							"@PasswordChangedTime,"+
							"@LockoutTime,"+
							"@LoginFailedCount,"+
							"@FirstFailedTime,"+
							"@FailedAnswerCount,"+
							"@FirstFailedAnswerTime,"+
							"@UserStatus,"+
							"@CheckNum,"+
							"@IsResetPassword,"+
							"@UserCultureName,"+
							"@UserFace,"+
							"@FaceWidth,"+
							"@FaceHeight,"+
							"@Sign,"+
							"@PrivacySetting,"+
							"@Balance,"+
							"@UserPoint,"+
							"@UserExp,"+
							"@ConsumeMoney,"+
							"@ConsumePoint,"+
							"@ConsumeExp,"+
							"@PostItems,"+
							"@PassedItems,"+
							"@RejectItems,"+
							"@DeleteItems,"+
							"@EndTime,"+
							"@IsInheritGroupRole,"+
							"@UserSetting,"+
							"@UserFriendGroup,"+
							"@PayPassword,"+
							"@IsShowUpgradeTipsFalse,"+
							"@LastAddPointTime,"+
							"@QAPoint,"+
							"@GetPasswordSid,"+
							"@GetPasswordTime,"+
							"@HonorType,"+
							"@FrozenBalance,"+
							"@CreditLines)";
			if(_DB.ExeSQLResult(strSQL,dict))
			{
				return DataConverter.CLng(entity.UserID);
			}
			return -1;
		}
		/// <summary>
		/// 增加一条记录，返回新的ID号。需要有一个单一主键，并且开启有标识符属性（异步方式）
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <returns></returns>
		public virtual async Task<int> InsertAsync(UsersEntity entity)
		{
			if(entity.UserID <= 0) entity.UserID=GetNewID();			
			Dictionary<string, object> dict = new Dictionary<string, object>();
			GetParameters(entity,dict);

			string strSQL = "insert into Users ("+
							"UserID,"+
							"GroupID,"+
							"CompanyID,"+
							"ClientID,"+
							"UserType,"+
							"UserName,"+
							"TrueName,"+
							"UserPassword,"+
							"LastPassword,"+
							"Question,"+
							"Answer,"+
							"Email,"+
							"Mobile,"+
							"Sex,"+
							"RegTime,"+
							"JoinTime,"+
							"LoginTimes,"+
							"LoginTime,"+
							"PresentTime,"+
							"LoginIP,"+
							"PasswordChangedTime,"+
							"LockoutTime,"+
							"LoginFailedCount,"+
							"FirstFailedTime,"+
							"FailedAnswerCount,"+
							"FirstFailedAnswerTime,"+
							"UserStatus,"+
							"CheckNum,"+
							"IsResetPassword,"+
							"UserCultureName,"+
							"UserFace,"+
							"FaceWidth,"+
							"FaceHeight,"+
							"Sign,"+
							"PrivacySetting,"+
							"Balance,"+
							"UserPoint,"+
							"UserExp,"+
							"ConsumeMoney,"+
							"ConsumePoint,"+
							"ConsumeExp,"+
							"PostItems,"+
							"PassedItems,"+
							"RejectItems,"+
							"DeleteItems,"+
							"EndTime,"+
							"IsInheritGroupRole,"+
							"UserSetting,"+
							"UserFriendGroup,"+
							"PayPassword,"+
							"IsShowUpgradeTipsFalse,"+
							"LastAddPointTime,"+
							"QAPoint,"+
							"GetPasswordSid,"+
							"GetPasswordTime,"+
							"HonorType,"+
							"FrozenBalance,"+
							"CreditLines) "+
							"values("+
							"@UserID,"+
							"@GroupID,"+
							"@CompanyID,"+
							"@ClientID,"+
							"@UserType,"+
							"@UserName,"+
							"@TrueName,"+
							"@UserPassword,"+
							"@LastPassword,"+
							"@Question,"+
							"@Answer,"+
							"@Email,"+
							"@Mobile,"+
							"@Sex,"+
							"@RegTime,"+
							"@JoinTime,"+
							"@LoginTimes,"+
							"@LoginTime,"+
							"@PresentTime,"+
							"@LoginIP,"+
							"@PasswordChangedTime,"+
							"@LockoutTime,"+
							"@LoginFailedCount,"+
							"@FirstFailedTime,"+
							"@FailedAnswerCount,"+
							"@FirstFailedAnswerTime,"+
							"@UserStatus,"+
							"@CheckNum,"+
							"@IsResetPassword,"+
							"@UserCultureName,"+
							"@UserFace,"+
							"@FaceWidth,"+
							"@FaceHeight,"+
							"@Sign,"+
							"@PrivacySetting,"+
							"@Balance,"+
							"@UserPoint,"+
							"@UserExp,"+
							"@ConsumeMoney,"+
							"@ConsumePoint,"+
							"@ConsumeExp,"+
							"@PostItems,"+
							"@PassedItems,"+
							"@RejectItems,"+
							"@DeleteItems,"+
							"@EndTime,"+
							"@IsInheritGroupRole,"+
							"@UserSetting,"+
							"@UserFriendGroup,"+
							"@PayPassword,"+
							"@IsShowUpgradeTipsFalse,"+
							"@LastAddPointTime,"+
							"@QAPoint,"+
							"@GetPasswordSid,"+
							"@GetPasswordTime,"+
							"@HonorType,"+
							"@FrozenBalance,"+
							"@CreditLines)";
			if(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)))
			{
				return DataConverter.CLng(entity.UserID);
			}
			return -1;
		}

		/// <summary>
		/// 增加或更新一条记录
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <param name="IsSave">是否增加</param>
		/// <returns></returns>
		public virtual bool AddOrUpdate(UsersEntity entity, bool IsSave)
		{
			return IsSave ? Add(entity) : Update(entity);
		}
		/// <summary>
		/// 增加或更新一条记录（异步方式）
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <param name="IsSave">是否增加</param>
		/// <returns></returns>
		public virtual async Task<bool> AddOrUpdateAsync(UsersEntity entity, bool IsSave)
		{
			return IsSave ? await AddAsync(entity) : await UpdateAsync(entity);
		}
		#endregion
		
		#region 删除
		/// <summary>
		/// 通过主键删除
		/// </summary>
		/// <returns></returns>
		public bool Delete(System.Int32 userID)
		{
			string strSQL = "delete from Users where " +
			
			"UserID = @UserID"; 
			
			Dictionary<string, object> dict = new Dictionary<string, object>();
			dict.Add("UserID", userID);
			
			return _DB.ExeSQLResult(strSQL, dict);
		}
		/// <summary>
		/// 通过主键删除
		/// </summary>
		/// <returns></returns>
		public async Task<bool> DeleteAsync(System.Int32 userID)
		{
			string strSQL = "delete from Users where " +
			
			"UserID = @UserID"; 
			
			Dictionary<string, object> dict = new Dictionary<string, object>();
			dict.Add("UserID", userID);
			
			return await Task.Run(() => _DB.ExeSQLResult(strSQL, dict));
		}
		
		/// <summary>
		/// 删除一条或多条记录
		/// </summary>
		/// <param name="strWhere">参数化删除条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual bool Delete(string strWhere, Dictionary<string, object> dict = null)
		{
			string strSQL = "delete from Users where 1=1 " + strWhere;
			return _DB.ExeSQLResult(strSQL, dict);
		}
		/// <summary>
		/// 删除一条或多条记录（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化删除条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<bool> DeleteAsync(string strWhere, Dictionary<string, object> dict = null)
		{
			string strSQL = "delete from Users where 1=1 " + strWhere;
			return await Task.Run(() => _DB.ExeSQLResult(strSQL, dict));
		}
		#endregion
		
		#region 修改
		/// <summary>
		/// 更新一条记录
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <returns></returns>
		public virtual bool Update(UsersEntity entity)
		{
			Dictionary<string, object> dict = new Dictionary<string, object>();
			GetParameters(entity, dict);
			string strSQL = "Update Users SET "+
			"GroupID = @GroupID,"+
			"CompanyID = @CompanyID,"+
			"ClientID = @ClientID,"+
			"UserType = @UserType,"+
			"UserName = @UserName,"+
			"TrueName = @TrueName,"+
			"UserPassword = @UserPassword,"+
			"LastPassword = @LastPassword,"+
			"Question = @Question,"+
			"Answer = @Answer,"+
			"Email = @Email,"+
			"Mobile = @Mobile,"+
			"Sex = @Sex,"+
			"RegTime = @RegTime,"+
			"JoinTime = @JoinTime,"+
			"LoginTimes = @LoginTimes,"+
			"LoginTime = @LoginTime,"+
			"PresentTime = @PresentTime,"+
			"LoginIP = @LoginIP,"+
			"PasswordChangedTime = @PasswordChangedTime,"+
			"LockoutTime = @LockoutTime,"+
			"LoginFailedCount = @LoginFailedCount,"+
			"FirstFailedTime = @FirstFailedTime,"+
			"FailedAnswerCount = @FailedAnswerCount,"+
			"FirstFailedAnswerTime = @FirstFailedAnswerTime,"+
			"UserStatus = @UserStatus,"+
			"CheckNum = @CheckNum,"+
			"IsResetPassword = @IsResetPassword,"+
			"UserCultureName = @UserCultureName,"+
			"UserFace = @UserFace,"+
			"FaceWidth = @FaceWidth,"+
			"FaceHeight = @FaceHeight,"+
			"Sign = @Sign,"+
			"PrivacySetting = @PrivacySetting,"+
			"Balance = @Balance,"+
			"UserPoint = @UserPoint,"+
			"UserExp = @UserExp,"+
			"ConsumeMoney = @ConsumeMoney,"+
			"ConsumePoint = @ConsumePoint,"+
			"ConsumeExp = @ConsumeExp,"+
			"PostItems = @PostItems,"+
			"PassedItems = @PassedItems,"+
			"RejectItems = @RejectItems,"+
			"DeleteItems = @DeleteItems,"+
			"EndTime = @EndTime,"+
			"IsInheritGroupRole = @IsInheritGroupRole,"+
			"UserSetting = @UserSetting,"+
			"UserFriendGroup = @UserFriendGroup,"+
			"PayPassword = @PayPassword,"+
			"IsShowUpgradeTipsFalse = @IsShowUpgradeTipsFalse,"+
			"LastAddPointTime = @LastAddPointTime,"+
			"QAPoint = @QAPoint,"+
			"GetPasswordSid = @GetPasswordSid,"+
			"GetPasswordTime = @GetPasswordTime,"+
			"HonorType = @HonorType,"+
			"FrozenBalance = @FrozenBalance,"+
			"CreditLines = @CreditLines"+
			" WHERE "+
			
			"UserID = @UserID"; 
			
			return _DB.ExeSQLResult(strSQL, dict);
		}
		/// <summary>
		/// 更新一条记录（异步方式）
		/// </summary>
		/// <param name="entity">实体模型</param>
		/// <returns></returns>
		public virtual async Task<bool> UpdateAsync(UsersEntity entity)
		{
			Dictionary<string, object> dict = new Dictionary<string, object>();
			GetParameters(entity, dict);
			string strSQL = "Update Users SET "+
			"GroupID = @GroupID,"+
			"CompanyID = @CompanyID,"+
			"ClientID = @ClientID,"+
			"UserType = @UserType,"+
			"UserName = @UserName,"+
			"TrueName = @TrueName,"+
			"UserPassword = @UserPassword,"+
			"LastPassword = @LastPassword,"+
			"Question = @Question,"+
			"Answer = @Answer,"+
			"Email = @Email,"+
			"Mobile = @Mobile,"+
			"Sex = @Sex,"+
			"RegTime = @RegTime,"+
			"JoinTime = @JoinTime,"+
			"LoginTimes = @LoginTimes,"+
			"LoginTime = @LoginTime,"+
			"PresentTime = @PresentTime,"+
			"LoginIP = @LoginIP,"+
			"PasswordChangedTime = @PasswordChangedTime,"+
			"LockoutTime = @LockoutTime,"+
			"LoginFailedCount = @LoginFailedCount,"+
			"FirstFailedTime = @FirstFailedTime,"+
			"FailedAnswerCount = @FailedAnswerCount,"+
			"FirstFailedAnswerTime = @FirstFailedAnswerTime,"+
			"UserStatus = @UserStatus,"+
			"CheckNum = @CheckNum,"+
			"IsResetPassword = @IsResetPassword,"+
			"UserCultureName = @UserCultureName,"+
			"UserFace = @UserFace,"+
			"FaceWidth = @FaceWidth,"+
			"FaceHeight = @FaceHeight,"+
			"Sign = @Sign,"+
			"PrivacySetting = @PrivacySetting,"+
			"Balance = @Balance,"+
			"UserPoint = @UserPoint,"+
			"UserExp = @UserExp,"+
			"ConsumeMoney = @ConsumeMoney,"+
			"ConsumePoint = @ConsumePoint,"+
			"ConsumeExp = @ConsumeExp,"+
			"PostItems = @PostItems,"+
			"PassedItems = @PassedItems,"+
			"RejectItems = @RejectItems,"+
			"DeleteItems = @DeleteItems,"+
			"EndTime = @EndTime,"+
			"IsInheritGroupRole = @IsInheritGroupRole,"+
			"UserSetting = @UserSetting,"+
			"UserFriendGroup = @UserFriendGroup,"+
			"PayPassword = @PayPassword,"+
			"IsShowUpgradeTipsFalse = @IsShowUpgradeTipsFalse,"+
			"LastAddPointTime = @LastAddPointTime,"+
			"QAPoint = @QAPoint,"+
			"GetPasswordSid = @GetPasswordSid,"+
			"GetPasswordTime = @GetPasswordTime,"+
			"HonorType = @HonorType,"+
			"FrozenBalance = @FrozenBalance,"+
			"CreditLines = @CreditLines"+
			" WHERE "+
			
			"UserID = @UserID"; 
			return await Task.Run(() => _DB.ExeSQLResult(strSQL, dict));
		}

		/// <summary>
		/// 修改一条或多条记录
		/// </summary>
		/// <param name="strColumns">参数化要修改的列（如：ID = @ID,Name = @Name）</param>
		/// <param name="dictColumns">包含要修改的名称和值的集合,对应strColumns参数中要修改列的值</param>
		/// <param name="strWhere">参数化修改条件(例如: and ID = @ID)</param>
		/// <param name="dictWhere">包含查询名称和值的集合,对应strWhere参数中的值</param>
		/// <returns></returns>
		public virtual bool Update(string strColumns, Dictionary<string, object> dictColumns = null, string strWhere = "", Dictionary<string, object> dictWhere = null)
		{
			if (string.IsNullOrEmpty(strColumns))
				return false;

			strColumns = StringHelper.ReplaceIgnoreCase(strColumns, "@", "@UP_");
			string strSQL = "Update Users SET " + strColumns + " where 1=1 " + strWhere;

			Dictionary<string, object> dict = new Dictionary<string, object>();
			//生成要修改列的参数
			foreach (KeyValuePair<string, object> kvp in dictColumns)
			{
				dict.Add("@UP_" + kvp.Key,kvp.Value);
			}
			//生成查询条件的参数
			foreach (KeyValuePair<string, object> kvp in dictWhere)
			{
				dict.Add(kvp.Key, kvp.Value);
			}

			return _DB.ExeSQLResult(strSQL, dict);
		}
		/// <summary>
		/// 修改一条或多条记录（异步方式）
		/// </summary>
		/// <param name="strColumns">参数化要修改的列（如：ID = @ID,Name = @Name）</param>
		/// <param name="dictColumns">包含要修改的名称和值的集合,对应strColumns参数中要修改列的值</param>
		/// <param name="strWhere">参数化修改条件(例如: and ID = @ID)</param>
		/// <param name="dictWhere">包含查询名称和值的集合,对应strWhere参数中的值</param>
		/// <returns></returns>
		public virtual async Task<bool> UpdateAsync(string strColumns, Dictionary<string, object> dictColumns = null, string strWhere = "", Dictionary<string, object> dictWhere = null)
		{
			if (string.IsNullOrEmpty(strColumns))
				return false;

			strColumns = StringHelper.ReplaceIgnoreCase(strColumns, "@", "@UP_");
			string strSQL = "Update Users SET " + strColumns + " where 1=1 " + strWhere;

			Dictionary<string, object> dict = new Dictionary<string, object>();
			//生成要修改列的参数
			foreach (KeyValuePair<string, object> kvp in dictColumns)
			{
				dict.Add("@UP_" + kvp.Key, kvp.Value);
			}
			//生成查询条件的参数
			foreach (KeyValuePair<string, object> kvp in dictWhere)
			{
				dict.Add(kvp.Key, kvp.Value);
			}
			return await Task.Run(() => _DB.ExeSQLResult(strSQL, dict));
		}
		#endregion
		
		#region 得到实体
		/// <summary>
		/// 通过主键返回第一条信息的实体类。
		/// </summary>
		/// <returns></returns>
		public UsersEntity GetEntity(System.Int32 userID)
		{
			string strCondition = string.Empty;
			strCondition += " and UserID = @UserID";
			
			Dictionary<string, object> dict = new Dictionary<string, object>();
			dict.Add("UserID", userID);
			
			return GetEntity(strCondition,dict);
		}
		/// <summary>
		/// 通过主键返回第一条信息的实体类。
		/// </summary>
		/// <returns></returns>
		public async Task<UsersEntity> GetEntityAsync(System.Int32 userID)
		{
			string strCondition = string.Empty;
			strCondition += " and UserID = @UserID";
			
			Dictionary<string, object> dict = new Dictionary<string, object>();
			dict.Add("UserID", userID);
			
			return await GetEntityAsync(strCondition,dict);
		}
		
		/// <summary>
		/// 获取实体
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual UsersEntity GetEntity(string strWhere, Dictionary<string, object> dict = null)
		{
			UsersEntity obj = null;
			string strSQL = "select top 1 * from Users where 1=1 " + strWhere;
			using (NullableDataReader reader = _DB.GetDataReader(strSQL, dict))
			{
				if (reader.Read())
				{
					obj = GetEntityFromrdr(reader);
				}
			}
			return obj;
		}
		/// <summary>
		/// 获取实体（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<UsersEntity> GetEntityAsync(string strWhere, Dictionary<string, object> dict = null)
		{
			UsersEntity obj = null;
			string strSQL = "select top 1 * from Users where 1=1 " + strWhere;
			using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
			{
				if (reader.Read())
				{
					obj = GetEntityFromrdr(reader);
				}
			}
			return obj;
		}
		#endregion
		
		#region 得到实体列表
		/// <summary>
		/// 得到实体列表
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual IList<UsersEntity> GetEntityList(string strWhere="", Dictionary<string, object> dict = null)
		{
			IList<UsersEntity> list = new List<UsersEntity>();
			string strSQL = "select * from Users where 1=1 ";
			if(!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			using (NullableDataReader reader = _DB.GetDataReader(strSQL, dict))
			{
				while (reader.Read())
				{
					list.Add(GetEntityFromrdr(reader));
				}
			}
			return list;
		}
		/// <summary>
		/// 得到实体列表（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<IList<UsersEntity>> GetEntityListAsync(string strWhere = "", Dictionary<string, object> dict = null)
		{
			IList<UsersEntity> list = new List<UsersEntity>();
			string strSQL = "select * from Users where 1=1 ";
			if (!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
			{
				while (reader.Read())
				{
					list.Add(GetEntityFromrdr(reader));
				}
			}
			return list;
		}
		#endregion
		
		#region 得到数据列表
		/// <summary>
		/// 返回所有信息
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual DataTable GetAllData(string strWhere = "", Dictionary<string, object> dict = null)
		{
			string strSQL = "select * from Users where 1=1 ";
			if(!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			return _DB.GetDataTable(strSQL, dict);
		}
		/// <summary>
		/// 返回所有信息（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <returns></returns>
		public virtual async Task<DataTable> GetAllDataAsync(string strWhere = "", Dictionary<string, object> dict = null)
		{
			string strSQL = "select * from Users where 1=1 ";
			if(!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			return await Task.Run(() => _DB.GetDataTable(strSQL, dict));
		}

		/// <summary>
		/// 返回所有信息
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <param name="strExtended">返回的指定列(例如: extended = id + name 或 distinct name)</param>
		/// <returns></returns>
		public virtual DataTable GetAllData(string strWhere = "", Dictionary<string, object> dict = null, string strExtended="*")
		{
			string strSQL = "select " + strExtended + " from Users where 1=1 ";
			if(!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			return _DB.GetDataTable(strSQL, dict);
		}
		/// <summary>
		/// 返回所有信息（异步方式）
		/// </summary>
		/// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
		/// <param name="dict">参数的名/值集合</param>
		/// <param name="strExtended">返回的指定列(例如: extended = id + name 或 distinct name)</param>
		/// <returns></returns>
		public virtual async Task<DataTable> GetAllDataAsync(string strWhere = "", Dictionary<string, object> dict = null, string strExtended = "*")
		{
			string strSQL = "select " + strExtended + " from Users where 1=1 ";
			if(!string.IsNullOrEmpty(strWhere))
			{
				strSQL += strWhere;
			}
			return await Task.Run(() => _DB.GetDataTable(strSQL, dict));
		}
		#endregion
		
		#region 分页
		/// <summary>
		/// 通过存储过程"Common_GetList"，得到分页后的数据
		/// </summary>
		/// <param name="startRowIndexId">开始行索引</param>
        /// <param name="maxNumberRows">每页最大显示数量</param>
        /// <param name="Filter">查询条件(例如: Name = 'name' and id=1 )</param>
		/// <param name="Total">输出参数：查询总数</param>
		/// <returns></returns>
		public IList<UsersEntity> GetList(int startRowIndexId, int maxNumberRows,string Filter, out int Total)
		{
			Total = 0;
			return GetList(startRowIndexId,maxNumberRows,"","","",Filter,"",out Total);
		}
		/// <summary>
		/// 通过存储过程“Common_GetList”，得到分页后的数据
		/// </summary>
		/// <param name="startRowIndexId">开始行索引</param>
		/// <param name="maxNumberRows">每页最大显示数量</param>
		/// <param name="SortColumn">排序字段名，只能指定一个字段</param>
		/// <param name="StrColumn">返回列名</param>
		/// <param name="Sorts">排序方式（DESC,ASC）</param>
		/// <param name="Filter">查询条件(例如: Name = 'name' and id=1 )</param>
		/// <param name="TableName">查询表名，可以指定联合查询的SQL语句(例如: Comment LEFT JOIN Users ON Comment.UserName = Users.UserName)</param>
		/// <param name="Total">输出参数：查询总数</param>
		/// <returns></returns>
		public virtual IList<UsersEntity> GetList(int startRowIndexId, int maxNumberRows, string SortColumn, string StrColumn, string Sorts, string Filter, string TableName, out int Total)
		{
			IList<UsersEntity> list = new List<UsersEntity>();
			if (string.IsNullOrEmpty(SortColumn))
			{
				SortColumn = "UserID";
			}
			if (string.IsNullOrEmpty(StrColumn))
			{
				StrColumn = "*";
			}
			if (string.IsNullOrEmpty(Sorts))
			{
				Sorts = "DESC";
			}
			if (string.IsNullOrEmpty(TableName))
			{
				TableName = "Users";
			}
			string storedProcedureName = "Common_GetList";
			SqlParameter parmStartRows = new SqlParameter("StartRows", startRowIndexId);
			SqlParameter parmPageSize = new SqlParameter("PageSize", maxNumberRows);
			SqlParameter parmSortColumn = new SqlParameter("SortColumn", SortColumn);
			SqlParameter parmStrColumn = new SqlParameter("StrColumn", StrColumn);
			SqlParameter parmSorts = new SqlParameter("Sorts", Sorts);
			SqlParameter parmTableName = new SqlParameter("TableName", TableName);
			SqlParameter parmFilter = new SqlParameter("Filter", Filter);
			SqlParameter parmTotal = new SqlParameter("Total", SqlDbType.Int);
			parmTotal.Direction = ParameterDirection.Output;
			IDataParameter[] parameterArray = new IDataParameter[8];
			parameterArray[0] = parmStartRows;
			parameterArray[1] = parmPageSize;
			parameterArray[2] = parmSortColumn;
			parameterArray[3] = parmStrColumn;
			parameterArray[4] = parmSorts;
			parameterArray[5] = parmTableName;
			parameterArray[6] = parmFilter;
			parameterArray[7] = parmTotal;
			using (NullableDataReader reader = _DB.GetDataReaderByProc(storedProcedureName, parameterArray))
			{
				while (reader.Read())
				{
					list.Add(GetEntityFromrdr(reader));
				}
			}
			Total = (int)parmTotal.Value;
			return list;
		}

		/// <summary>
		/// 通过存储过程"Common_GetListBySortColumn"，得到分页后的数据
		/// </summary>
		/// <param name="startRowIndexId">开始行索引</param>
        /// <param name="maxNumberRows">每页最大显示数量</param>
        /// <param name="Filter">查询条件(例如: Name = 'name' and id=1 )</param>
		/// <param name="Total">输出参数：查询总数</param>
		/// <returns></returns>
		public IList<UsersEntity> GetListBySortColumn(int startRowIndexId, int maxNumberRows,string Filter, out int Total)
		{
			Total = 0;
			return GetListBySortColumn(startRowIndexId,maxNumberRows,"","","","","",Filter,"",out Total);
		}
		/// <summary>
		/// 通过存储过程"Common_GetListBySortColumn"，得到分页后的数据
		/// </summary>
		/// <param name="startRowIndexId">开始行索引</param>
        /// <param name="maxNumberRows">每页最大显示数量</param>
		/// <param name="Sorts">排序方式（DESC,ASC）</param>
        /// <param name="Filter">查询条件(例如: Name = 'name' and id=1 )</param>
		/// <param name="Total">输出参数：查询总数</param>
		/// <returns></returns>
		public IList<UsersEntity> GetListBySortColumn(int startRowIndexId, int maxNumberRows,string Sorts,string Filter, out int Total)
		{
			Total = 0;
			return GetListBySortColumn(startRowIndexId,maxNumberRows,"","","","",Sorts,Filter,"",out Total);
		}
		/// <summary>
		/// 通过存储过程“Common_GetListBySortColumn”，得到分页后的数据
		/// </summary>
		/// <param name="startRowIndexId">开始行索引</param>
		/// <param name="maxNumberRows">每页最大显示数量</param>
		/// <param name="PrimaryColumn">主键字段名</param>
		/// <param name="SortColumnDbType">排序字段的数据类型(如：int)</param>
		/// <param name="SortColumn">排序字段名，只能指定一个字段</param>
		/// <param name="StrColumn">返回列名</param>
		/// <param name="Sorts">排序方式（DESC,ASC）</param>
		/// <param name="Filter">查询条件(例如: Name = 'name' and id=1 )</param>
		/// <param name="TableName">查询表名，可以指定联合查询的SQL语句(例如: Comment LEFT JOIN Users ON Comment.UserName = Users.UserName)</param>
		/// <param name="Total">输出参数：查询总数</param>
		/// <returns></returns>
		public virtual IList<UsersEntity> GetListBySortColumn(int startRowIndexId, int maxNumberRows, string PrimaryColumn, string SortColumnDbType, string SortColumn, string StrColumn, string Sorts, string Filter, string TableName, out int Total)
		{
			IList<UsersEntity> list = new List<UsersEntity>();
			if (string.IsNullOrEmpty(PrimaryColumn))
			{
				PrimaryColumn = "UserID";
			}
			if (string.IsNullOrEmpty(SortColumnDbType))
			{
				SortColumnDbType = "int";
			}
			if (string.IsNullOrEmpty(SortColumn))
			{
				SortColumn = "UserID";
			}
			if (string.IsNullOrEmpty(StrColumn))
			{
				StrColumn = "*";
			}
			if (string.IsNullOrEmpty(Sorts))
			{
				Sorts = "DESC";
			}
			if (string.IsNullOrEmpty(TableName))
			{
				TableName = "Users";
			}
			string storedProcedureName = "Common_GetListBySortColumn";
			SqlParameter parmStartRows = new SqlParameter("StartRows", startRowIndexId);
			SqlParameter parmPageSize = new SqlParameter("PageSize", maxNumberRows);
			SqlParameter parmPrimaryColumn = new SqlParameter("PrimaryColumn", PrimaryColumn);
			SqlParameter parmSortColumnDbType = new SqlParameter("SortColumnDbType", SortColumnDbType);
			SqlParameter parmSortColumn = new SqlParameter("SortColumn", SortColumn);
			SqlParameter parmStrColumn = new SqlParameter("StrColumn", StrColumn);
			SqlParameter parmSorts = new SqlParameter("Sorts", Sorts);
			SqlParameter parmTableName = new SqlParameter("TableName", TableName);
			SqlParameter parmFilter = new SqlParameter("Filter", Filter);
			SqlParameter parmTotal = new SqlParameter("Total", SqlDbType.Int);
			parmTotal.Direction = ParameterDirection.Output;
			IDataParameter[] parameterArray = new IDataParameter[10];
			parameterArray[0] = parmStartRows;
			parameterArray[1] = parmPageSize;
			parameterArray[2] = parmPrimaryColumn;
			parameterArray[3] = parmSortColumnDbType;
			parameterArray[4] = parmSortColumn;
			parameterArray[5] = parmStrColumn;
			parameterArray[6] = parmSorts;
			parameterArray[7] = parmTableName;
			parameterArray[8] = parmFilter;
			parameterArray[9] = parmTotal;
			using (NullableDataReader reader = _DB.GetDataReaderByProc(storedProcedureName, parameterArray))
			{
				while (reader.Read())
				{
					list.Add(GetEntityFromrdr(reader));
				}
			}
			Total = (int)parmTotal.Value;
			return list;
		}
		#endregion
		
		#region 辅助方法
		/// <summary>
		/// 把实体类转换成键/值对集合
		/// </summary>
		/// <param name="entity"></param>
		/// <param name="dict"></param>
		private static void GetParameters(UsersEntity entity, Dictionary<string, object> dict)
		{
			dict.Add("UserID", entity.UserID);
			dict.Add("GroupID", entity.GroupID);
			dict.Add("CompanyID", entity.CompanyID);
			dict.Add("ClientID", entity.ClientID);
			dict.Add("UserType", entity.UserType);
			dict.Add("UserName", entity.UserName);
			dict.Add("TrueName", entity.TrueName);
			dict.Add("UserPassword", entity.UserPassword);
			dict.Add("LastPassword", entity.LastPassword);
			dict.Add("Question", entity.Question);
			dict.Add("Answer", entity.Answer);
			dict.Add("Email", entity.Email);
			dict.Add("Mobile", entity.Mobile);
			dict.Add("Sex", entity.Sex);
			dict.Add("RegTime", entity.RegTime);
			dict.Add("JoinTime", entity.JoinTime);
			dict.Add("LoginTimes", entity.LoginTimes);
			dict.Add("LoginTime", entity.LoginTime);
			dict.Add("PresentTime", entity.PresentTime);
			dict.Add("LoginIP", entity.LoginIP);
			dict.Add("PasswordChangedTime", entity.PasswordChangedTime);
			dict.Add("LockoutTime", entity.LockoutTime);
			dict.Add("LoginFailedCount", entity.LoginFailedCount);
			dict.Add("FirstFailedTime", entity.FirstFailedTime);
			dict.Add("FailedAnswerCount", entity.FailedAnswerCount);
			dict.Add("FirstFailedAnswerTime", entity.FirstFailedAnswerTime);
			dict.Add("UserStatus", entity.UserStatus);
			dict.Add("CheckNum", entity.CheckNum);
			dict.Add("IsResetPassword", entity.IsResetPassword);
			dict.Add("UserCultureName", entity.UserCultureName);
			dict.Add("UserFace", entity.UserFace);
			dict.Add("FaceWidth", entity.FaceWidth);
			dict.Add("FaceHeight", entity.FaceHeight);
			dict.Add("Sign", entity.Sign);
			dict.Add("PrivacySetting", entity.PrivacySetting);
			dict.Add("Balance", entity.Balance);
			dict.Add("UserPoint", entity.UserPoint);
			dict.Add("UserExp", entity.UserExp);
			dict.Add("ConsumeMoney", entity.ConsumeMoney);
			dict.Add("ConsumePoint", entity.ConsumePoint);
			dict.Add("ConsumeExp", entity.ConsumeExp);
			dict.Add("PostItems", entity.PostItems);
			dict.Add("PassedItems", entity.PassedItems);
			dict.Add("RejectItems", entity.RejectItems);
			dict.Add("DeleteItems", entity.DeleteItems);
			dict.Add("EndTime", entity.EndTime);
			dict.Add("IsInheritGroupRole", entity.IsInheritGroupRole);
			dict.Add("UserSetting", entity.UserSetting);
			dict.Add("UserFriendGroup", entity.UserFriendGroup);
			dict.Add("PayPassword", entity.PayPassword);
			dict.Add("IsShowUpgradeTipsFalse", entity.IsShowUpgradeTipsFalse);
			dict.Add("LastAddPointTime", entity.LastAddPointTime);
			dict.Add("QAPoint", entity.QAPoint);
			dict.Add("GetPasswordSid", entity.GetPasswordSid);
			dict.Add("GetPasswordTime", entity.GetPasswordTime);
			dict.Add("HonorType", entity.HonorType);
			dict.Add("FrozenBalance", entity.FrozenBalance);
			dict.Add("CreditLines", entity.CreditLines);
		}
		/// <summary>
		/// 通过数据读取器生成实体类
		/// </summary>
		/// <param name="rdr"></param>
		/// <returns></returns>
		private static UsersEntity GetEntityFromrdr(NullableDataReader rdr)
		{
			UsersEntity info = new UsersEntity();
			info.UserID = rdr.GetInt32("UserID");
			info.GroupID = rdr.GetInt32("GroupID");
			info.CompanyID = rdr.GetInt32("CompanyID");
			info.ClientID = rdr.GetInt32("ClientID");
			info.UserType = rdr.GetInt32("UserType");
			info.UserName = rdr.GetString("UserName");
			info.TrueName = rdr.GetString("TrueName");
			info.UserPassword = rdr.GetString("UserPassword");
			info.LastPassword = rdr.GetString("LastPassword");
			info.Question = rdr.GetString("Question");
			info.Answer = rdr.GetString("Answer");
			info.Email = rdr.GetString("Email");
			info.Mobile = rdr.GetString("Mobile");
			info.Sex = rdr.GetInt32("Sex");
			info.RegTime = rdr.GetNullableDateTime("RegTime");
			info.JoinTime = rdr.GetNullableDateTime("JoinTime");
			info.LoginTimes = rdr.GetInt32("LoginTimes");
			info.LoginTime = rdr.GetNullableDateTime("LoginTime");
			info.PresentTime = rdr.GetNullableDateTime("PresentTime");
			info.LoginIP = rdr.GetString("LoginIP");
			info.PasswordChangedTime = rdr.GetNullableDateTime("PasswordChangedTime");
			info.LockoutTime = rdr.GetNullableDateTime("LockoutTime");
			info.LoginFailedCount = rdr.GetInt32("LoginFailedCount");
			info.FirstFailedTime = rdr.GetNullableDateTime("FirstFailedTime");
			info.FailedAnswerCount = rdr.GetInt32("FailedAnswerCount");
			info.FirstFailedAnswerTime = rdr.GetNullableDateTime("FirstFailedAnswerTime");
			info.UserStatus = rdr.GetInt32("UserStatus");
			info.CheckNum = rdr.GetString("CheckNum");
			info.IsResetPassword = rdr.GetBoolean("IsResetPassword");
			info.UserCultureName = rdr.GetString("UserCultureName");
			info.UserFace = rdr.GetString("UserFace");
			info.FaceWidth = rdr.GetInt32("FaceWidth");
			info.FaceHeight = rdr.GetInt32("FaceHeight");
			info.Sign = rdr.GetString("Sign");
			info.PrivacySetting = rdr.GetInt32("PrivacySetting");
			info.Balance = rdr.GetDecimal("Balance");
			info.UserPoint = rdr.GetInt32("UserPoint");
			info.UserExp = rdr.GetInt32("UserExp");
			info.ConsumeMoney = rdr.GetInt32("ConsumeMoney");
			info.ConsumePoint = rdr.GetInt32("ConsumePoint");
			info.ConsumeExp = rdr.GetInt32("ConsumeExp");
			info.PostItems = rdr.GetInt32("PostItems");
			info.PassedItems = rdr.GetInt32("PassedItems");
			info.RejectItems = rdr.GetInt32("RejectItems");
			info.DeleteItems = rdr.GetInt32("DeleteItems");
			info.EndTime = rdr.GetNullableDateTime("EndTime");
			info.IsInheritGroupRole = rdr.GetBoolean("IsInheritGroupRole");
			info.UserSetting = rdr.GetString("UserSetting");
			info.UserFriendGroup = rdr.GetString("UserFriendGroup");
			info.PayPassword = rdr.GetString("PayPassword");
			info.IsShowUpgradeTipsFalse = rdr.GetBoolean("IsShowUpgradeTipsFalse");
			info.LastAddPointTime = rdr.GetNullableDateTime("LastAddPointTime");
			info.QAPoint = rdr.GetInt32("QAPoint");
			info.GetPasswordSid = rdr.GetString("GetPasswordSid");
			info.GetPasswordTime = rdr.GetNullableDateTime("GetPasswordTime");
			info.HonorType = rdr.GetInt32("HonorType");
			info.FrozenBalance = rdr.GetDecimal("FrozenBalance");
			info.CreditLines = rdr.GetDecimal("CreditLines");
			return info;
		}
		#endregion
	}
}